package cn.xmoit.flowable.listener;

import org.flowable.engine.delegate.TaskListener;
import org.flowable.task.service.delegate.DelegateTask;
import org.springframework.stereotype.Component;

/**
 * @author fangyy
 */
@Component
public class SettingApproveUser implements TaskListener {

	@Override
	public void notify(DelegateTask delegateTask) {
		String approveType = (String) delegateTask.getVariable("approveType");
		delegateTask.setAssignee((String) delegateTask.getVariable("approveUser"));
		if ("by_user".equals(approveType)) {
			delegateTask.setAssignee((String) delegateTask.getVariable("approveUser"));
		}
		else if ("by_role".equals(approveType)) {
			Object approveRole = delegateTask.getVariable("approveRole");
			delegateTask.addCandidateGroup((String) approveRole);
		}
	}

}
